#!/bin/sh
#############################################
## main
## 以supervisord托管服务, control.sh脚本必须实现start方法
#############################################
# base info
BASEDIR=$(cd $(dirname $0) && pwd -P)
readonly DOMAIN_CONF=$BASEDIR/server.conf   # Nginx反向代理配置
#
readonly NGX_HOME=/home/xiaoju/openresty/
readonly NGX_BIN=$NGX_HOME/bin/openresty

start(){
    echo "starting nginx process"
    $NGX_BIN
    echo "start nginx process success."
    return $?
}

stop(){
    echo "stopting nginx process"
    $NGX_BIN -s stop
    echo "stop nginx process success."
    return $?
}

reload(){
    echo "reloading nginx process"
    $NGX_BIN -s reload
    echo "reload nginx process success."
    return $?
}

case $1 in
    "start" )
        # 启动服务
        echo "start"
        start
        ;;
    "stop" )
        # 停止服务
        echo "stop"
        stop
        ;;
    "reload" )
        # 重启服务
        echo "reload"
        reload
        ;;
    * )
        echo "unknown command.  arg start|stop|reload"
        exit 1
        ;;
esac
exit $?